# Contributor: Leo <thinkabit.ukim@gmail.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=flatbuffers
pkgver=1.12.0
pkgrel=0
pkgdesc="Memory Efficient Serialization Library"
url="https://google.github.io/flatbuffers/"
arch="all !s390x"
license="Apache-2.0"
makedepends="cmake"
subpackages="$pkgname-dev"
source="flatbuffers-$pkgver.tar.gz::https://github.com/google/flatbuffers/archive/v$pkgver.tar.gz"

# Tests fail with bus error
arch="$arch !armhf !mips !mips64"

build() {
	cmake -B build . \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DFLATBUFFERS_BUILD_SHAREDLIB=ON \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DCMAKE_BUILD_TYPE=None
	make -C build
}

check() {
	make -C build test
}

package() {
	make install -C build DESTDIR="$pkgdir"
	install -Dm755 "$builddir"/build/flatc \
		"$pkgdir"/usr/bin/flatc
}

sha512sums="8a0b88d739fa4694a69d3630140fe89fdd70d50bba4dadd1758d9aa2920cda16700bcafb8d89fe2a09ac907d3f378240c3cb4abc7106318136799836aba4b063  flatbuffers-1.12.0.tar.gz"
